#ifndef MESH_H_
#define MESH_H_

#include <vector>
#include <btBulletCollisionCommon.h>
#include <btBulletDynamicsCommon.h>
#include "math/Vector3.h"
#include "world/Prototype.h"
#include "mesh/Material.h"
#include "texture/Texture.h"
#include "texture/UVLayer.h"
#include "art/ShaderProgram.h"

struct Face {
	std::vector<int> vertices;
	std::vector<int> vertexNormals;
	Material *material;
};

struct MaterialGroup {
	Material *material;
	std::vector<Face*> faces;
};

/**
 * 3D geometry, materials, and textures representing some kind of object.
 */
class Mesh: public Prototype {
public:

	Mesh(std::vector<Vector3> vertices,
			std::vector<Vector3> vertexNormals,
			std::vector<Texture*> textures,
			std::vector<UVLayer*> uvLayers,
			std::vector<Material*> materials,
			std::vector<Face*> faces,
			ShaderProgram* program);

	void compile();
	virtual void draw();
	virtual ~Mesh();

    std::string getName() const {
		return name;
	}

	void setName(std::string name) {
		this->name = name;
	}

private:
	std::string name;

	std::vector<Vector3> vertices;
	std::vector<Vector3> vertexNormals;
	std::vector<Texture*> textures;
	std::vector<UVLayer*> uvLayers;
	std::vector<Material*> materials;
	std::vector<Face*> faces;

	unsigned int displayList;
};

#endif /* MESH_H_ */
